import { View } from '@tarojs/components';
import styles from './style.scss';
import { Check } from '@nutui/icons-react-taro';

type Props = {
  checked?: boolean;
  onChange?: (checked: boolean) => void;
};

export default ({ checked, onChange }: Props) => {
  return (
    <View
      className={`${styles.checkbox} ${checked ? styles.checked : ''}`}
      onClick={(e) => {
        e.stopPropagation();
        onChange?.(!checked);
      }}
    >
      <Check />
    </View>
  );
};
